package presenter

import (
	"github.com/emicklei/go-restful/v3"
)

type ResponseMsg struct {
	Status string `json:"status"`
	Msg    string `json:"msg"`
}

type JsonRes struct {
	Code int         `json:"code"`
	Msg  string      `json:"message"`
	Data interface{} `json:"data"`
}

func Json(response *restful.Response, code int, msg string, data interface{}) {
	res := JsonRes{
		Code: code,
		Msg:  msg,
		Data: struct {
		}{},
	}

	if data != nil {
		res.Data = data
	}
	_ = response.WriteAsJson(res)
	return
}
